# -*- coding: utf-8 -*-
# standard
import os
import sys

# third

# local
_P_PATH =  os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
if _P_PATH not in sys.path:
    sys.path.append(_P_PATH)
from functions import *


"""
@Title:   解析缺少音频的文件的文本, 修改对应的数据库记录以方便再次下载
@File: 解析缺少音频的文件的文本.py
@Author: walle 2024年01日15日 16时46分34秒
@Version: 1.0.0
@Desc: 
"""


def parse_file():
    file_path = os.path.join(_P_PATH, "test", 'LRS3_missing_audio.txt')
    keys = []
    with open(file_path, mode='r', encoding="utf-8") as lines:
        for line in lines:
            word = line.strip()
            if word:
                keys.append(word)
    return keys


def main():
    keys = parse_file()
    db_session = new_db_session()
    db_session.query(MediaFileOrm).filter(MediaFileOrm.key.in_(keys)).update({"need_audio": 1})
    db_session.commit()
    db_session.close()



if __name__ == '__main__':
    main()
    pass